package com.javasws.springsecuritydemo.controller;

import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author by javasws on 2021/11/28.
 */
@Controller
public class LoginController {

    /**
     * 登录
     *
     * @return
     */
//    @RequestMapping("/login")
//    public String login() {
//        return "redirect:main.html";
//    }
//    @Secured("ROLE_abc")
    @PreAuthorize("hasRole('abc')")
    @RequestMapping("/toMain")
    public String main() {
        return "redirect:main.html";
    }

    @RequestMapping("/toError")
    public String error() {
        return "redirect:error.html";
    }

    @RequestMapping("/demo")
    public String demo(){
        return "demo";
    }

    @RequestMapping("/showLogin")
    public String showLogin(){
        return "login";
    }
}
